/**
 * 获取当前日期所在周的日期
 * @param {String} inputDate 标准日期字符串或者毫秒数
 * 返回日期数组：[2022-01-01, 2022-01-07]
 */
import {
	timeFormat
} from '@/uni_modules/uview-plus';
export function getWeekDates(inputDate) {
	// 星期映射
	const days = [0, 1, 2, 3, 4, 5, 6];
	const date = new Date(inputDate);
	const dayOfWeek = date.getDay();
	const startDate = new Date(date);
	startDate.setDate(date.getDate() - (dayOfWeek == 0 ? 7 : dayOfWeek));

	const weekDates = [];
	for (let i = 1; i < 8; i++) {
		const currentDate = new Date(startDate);
		currentDate.setDate(startDate.getDate() + i);
		weekDates.push(timeFormat(new Date(currentDate).getTime(), 'yyyy-mm-dd'));
	}

	return [weekDates[0], weekDates[6]];
}


// 判断时间为那个季度的函数
export function getQuarter(date) {
	const month = date.getMonth() + 1; // 月份从0开始，需要加1
	if (month >= 1 && month <= 3) {
		return "第一季度";
	} else if (month >= 4 && month <= 6) {
		return "第二季度";
	} else if (month >= 7 && month <= 9) {
		return "第三季度";
	} else {
		return "第四季度";
	}
}